package com.yoake.campus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoake.common.annotation.Log;
import com.yoake.common.core.controller.BaseController;
import com.yoake.common.core.domain.AjaxResult;
import com.yoake.common.enums.BusinessType;
import com.yoake.campus.domain.CampusTag;
import com.yoake.campus.service.ICampusTagService;
import com.yoake.common.utils.poi.ExcelUtil;
import com.yoake.common.core.page.TableDataInfo;

/**
 * 标签管理Controller
 * 
 * @author yoake
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/campus/tag")
public class CampusTagController extends BaseController
{
    @Autowired
    private ICampusTagService campusTagService;

    /**
     * 查询标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('campus:tag:list')")
    @GetMapping("/list")
    public TableDataInfo list(CampusTag campusTag)
    {
        startPage();
        List<CampusTag> list = campusTagService.selectCampusTagList(campusTag);
        return getDataTable(list);
    }


    /**
     * 获取标签管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('campus:tag:query')")
    @GetMapping(value = "/{tagId}")
    public AjaxResult getInfo(@PathVariable("tagId") Long tagId)
    {
        return success(campusTagService.selectCampusTagByTagId(tagId));
    }

    /**
     * 新增标签管理
     */
    @PreAuthorize("@ss.hasPermi('campus:tag:add')")
    @Log(title = "标签管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CampusTag campusTag)
    {
        return toAjax(campusTagService.insertCampusTag(campusTag));
    }

    /**
     * 修改标签管理
     */
    @PreAuthorize("@ss.hasPermi('campus:tag:edit')")
    @Log(title = "标签管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CampusTag campusTag)
    {
        return toAjax(campusTagService.updateCampusTag(campusTag));
    }

    /**
     * 删除标签管理
     */
    @PreAuthorize("@ss.hasPermi('campus:tag:remove')")
    @Log(title = "标签管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagIds}")
    public AjaxResult remove(@PathVariable Long[] tagIds)
    {
        return toAjax(campusTagService.deleteCampusTagByTagIds(tagIds));
    }
}
